package com.zzedu.integration.sms.config;

import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.sms.v20210111.SmsClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(SmsConfig.class)
public class SmsInitConfig {
    @Autowired
    private SmsConfig smsConfig;


    @Bean
    public SmsClient smsClient(){
        /* 实例化要请求产品(以sms为例)的client对象
         * 第二个参数是地域信息，可以直接填写字符串ap-guangzhou，支持的地域列表参考 https://cloud.tencent.com/document/api/382/52071#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8 */
        return new SmsClient(new Credential(smsConfig.getSecretId(), smsConfig.getSecretKey()), smsConfig.getRegion());
    }
}
